﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OneMile.DAL;
using OneMile.Entity;
using OneMile.Entity.Model;

namespace OneMile.BLL
{
    public class BLLUOrder:BaseBLL
    {
        private DALUOrder dalOrder;
        public DALUOrder DALOrder
        {
            get
            {
                if (dalOrder == null)
                {
                    dalOrder = DALFactory.getInstance().CreateUOrderDAL();
                }
                return dalOrder;
            }
        }


        public IList<EOrderForList> GetOrderListByUserId(string userId,  int pageSize,int pageNo, string shopsType,int OrderType)
        {
            try
            {
                return DALOrder.GetOrderListByUserId(userId, pageSize, pageNo, shopsType, OrderType);
            }
            catch (Exception e)
            {
                base.WriteLog(e.Message);
                throw e;
            }
        }

        public bool InsertOrder(EOrder order)
        {
            try
            {   
                return DALOrder.InsertOrder(order);
            }
            catch (Exception e)
            {
                
                base.WriteLog(e.Message);
                throw e;
            }
        }

        public bool InsertOrderAgain(string orderId)
        {
            try
            {
                EOrder order=DALOrder.GetOrderByOrderId(new Guid(orderId));
                if (order == null)
                {
                    return false;
                }
                else
                {
                   return InsertOrder(order);
                }
            }
            catch (Exception e)
            {

                base.WriteLog(e.Message);
                throw e;
            }
        }

    }
}
